import 'package:ribo_base_core/base_enums/base_chart_axis_display.dart';

class BaseChartAxis {
  BaseChartAxisDisplay x;
  BaseChartAxisDisplay y;
  bool isBreak;

  BaseChartAxis(
      {this.x = BaseChartAxisDisplay.NONE, this.y = BaseChartAxisDisplay.NONE, this.isBreak = true});

  Map<String, dynamic> toJson() {
    Map<String, dynamic> map = {
      'xAxis': {
        'show': true,
        'position': 'bottom',
        'splitLine': <String,dynamic>{'show': false},
        'boundaryGap': true,
        'axisLabel': {
          'fontSize': 10,
          'interval': 0,
          if (isBreak) 'width': 36,
          if (isBreak) 'overflow': 'breakAll',
          'rotate': 0,
          'align': 'center'
        },
        'axisTick': {'interval': 0, 'length': 2, 'alignWithLabel': true},
      },
      'yAxis': {
        'show': true,
        'splitLine': <String,dynamic>{'show': false},
        'boundaryGap': true,
        'axisLabel': <String,dynamic>{'fontSize': 10},
        'axisTick': {'interval': 0, 'length': 2, 'alignWithLabel': true},
      }
    };
    switch (this.x) {
      case BaseChartAxisDisplay.NONE:
        map['xAxis']['show'] = false;
        break;
      case BaseChartAxisDisplay.VALUE:
        map['xAxis']['axisLine'] = {'show': false};
        map['xAxis']['axisTick'] = {'show': false};
        break;
      case BaseChartAxisDisplay.LINE:
        map['xAxis']['axisLabel'] = {'show': false};
        break;
      case BaseChartAxisDisplay.ALL:
      default:
        break;
    }
    switch (this.y) {
      case BaseChartAxisDisplay.NONE:
        map['yAxis']['show'] = false;
        break;
      case BaseChartAxisDisplay.VALUE:
        map['yAxis']['axisLine'] = {'show': false};
        map['yAxis']['axisTick'] = {'show': false};
        break;
      case BaseChartAxisDisplay.LINE:
        map['yAxis']['axisLabel'] = {'show': false};
        break;
      case BaseChartAxisDisplay.ALL:
      default:
        break;
    }
    return map;
  }
}
